#include "Surface.h"


Surface::Surface(void)
{
}
Surface::Surface(LPDIRECT3DDEVICE9 dv)
{
	cl=new COLOR();
	rect.left=200;
	rect.top=100;
	rect.right=400;
	rect.bottom=380;
	Create_back_buffer(dv);
	Create_suface(dv);
}

Surface::~Surface(void)
{
}

void Surface::Create_suface(LPDIRECT3DDEVICE9 dv)
{
		int result=
			dv->CreateOffscreenPlainSurface(
		100,
		100,
		D3DFMT_X8R8G8B8,
		D3DPOOL_DEFAULT,
		&suface,
		NULL
		);
}
void Surface::Create_back_buffer(LPDIRECT3DDEVICE9 dv)
{
	dv->GetBackBuffer(
		0,
		0,
		D3DBACKBUFFER_TYPE_MONO,
		&back_buffer
		);
}
void Surface::Draw_rect(LPDIRECT3DDEVICE9 dv)
{
	if(dv->BeginScene())
	{		
		cl->Set_Color(100,255,0,0);
		dv->ColorFill(suface,NULL,D3DCOLOR_XRGB(cl->Get_r(),cl->Get_g(),cl->Get_b()));	
	dv->StretchRect(
		suface,
		NULL,
		back_buffer,
		&rect,
		D3DTEXF_NONE
		);
	dv->EndScene();
	}
	dv->Present(NULL,NULL,NULL,NULL);
}
void Surface::Set_rect(int a,int b,int c,int d)
{
	rect.left+=a;
	rect.top+=b;
	rect.right+=c;
	rect.bottom+=d;
}